package main.prototype;

import java.io.IOException;
import java.util.HashMap;

/**
 * @author: kejl
 * @create: 2020-07-15 00:01
 */
public class PrototypeManger {

    private static PrototypeManger prototypeManger = new PrototypeManger();

    //to do 类的加载机制不能用 static
    private   HashMap<String,AbstractPrototype> prototypeMap = new HashMap<String,AbstractPrototype>();


    private PrototypeManger(){
        prototypeMap.put("a",new ConcretePrototype_A());
        prototypeMap.put("b",new ConcretePrototype_B());
    }

    public static PrototypeManger getPrototypeManger(){
        return  prototypeManger;
    }

    public  AbstractPrototype getPrototype(String type) throws IOException, ClassNotFoundException {
            return prototypeMap.get(type).deepClone();
    }





}
